<%= render Settings::ControlGroupComponent.new class: "mb-14" do |group| %>
  <% group.header do %>
    Payment History
  <% end %>

  <% if @next_payment_date %>
    <% group.item do %>
      <%= render Settings::ControlRowComponent.new do |row| %>
        <% row.title do %>
          <time datetime="<%= @next_payment_date.to_formatted_s(:date) %>"><%= @next_payment_date.to_formatted_s(:date) %></time>
        <% end %>
        <% row.control do %>
          <span class="text-500">Scheduled</span>
        <% end %>
      <% end %>
    <% end %>
  <% end %>

  <% @billing_events.first(limit).each do |invoice| %>
    <% group.item do %>
      <%= render Settings::ControlRowComponent.new do |row| %>
        <% row.title do %>
          <%= invoice.receipt_date %>
        <% end %>
        <% row.control do %>
          <%= link_to invoice do %>
            <%= number_to_currency(invoice.receipt_amount) %> <%= invoice.currency %> <%= invoice.receipt_description %> Receipt
          <% end %>
        <% end %>
      <% end %>
    <% end %>
  <% end %>
  <% if limit < @billing_events.count %>
    <% group.description do %>
      Showing last <%= limit %> of <%= number_with_delimiter(@billing_events.count) %> payments. <%= link_to "View all", payment_history_settings_billing_path %>.
    <% end %>
  <% end %>
<% end %>